<?php
/**
 * WAVESELF FRAMEWORK
 * 
 * Waveself framework is an open source project released under New BSD license.
 * Waveself Engine Team did this in order to help you as ourselves with different
 * but still easy to use and learn approach. 
 * 
 * Please read license before you do any changes or to say, before using current software
 * read our licence which can be found under waveself framework root folder.
 * 
 * If you did not recieve copy of licence, contact us immediately and we will send you copy.
 * 
 * @category   Waveself
 * @package    System Configuration
 * @author     Nevio Vesic <nevio.vesic@gmail.com>
 * @copyright  Waveself Framework NPO 2009-2010
 * @license    https://code.google.com/p/waveself-framework/source/browse/trunk/LICENSE   New-BSD
 * @version    0.1a
 */

/**
 * ...
 * 
 * @category    Waveself
 * @package     Engine
 * @subpackage  Abstract
 * @author      Nevio Vesic <nevio.vesic@gmail.com>
 * @copyright   Waveself Framework NPO 2009-2010
 * @version     1.0a
 */
abstract class Waveself_Engine_Abstract
{
	
	/** Waveself Enviroments */
	CONST ENV_SIMPLE     = 'simple';
	CONST ENV_AJAX       = 'ajax';
	
	/** Waveself Project Enviroments */
	CONST PROJ_STANDARD  = 'standard';
	CONST PROJ_SUBDOMAIN = 'subdomain';
	
	/** Predefined project access keys */
	CONST PAK_BACKEND    = 'backend';
	CONST PAK_MAIN       = 'main';
	
	/**
	 * Global Engine settings collector
	 *
	 * @var NULL|Array(Waveself_Settings)
	 */
	protected static $_settings = null;
	
	/**
	 * Waveself engine core components. Do not touch. Do not
	 * edit and do not erase it! It will be autopopulated.
	 * The best thing is to forget that this shit exist at all!
	 *
	 * @var NULL|Array[Waveself_Engine_*]
	 */
	protected static $_engineComponents = null;
	
	/**
	 * Resolved routing data static in order to be able get infos from
	 * complete project... We want DRY system.
	 *
	 * @var Array
	 */
	protected static $_routerData  = array();
	
	/**
	 * Enter description here...
	 *
	 * @var unknown_type
	 */
	protected static $_dispatcher  = null;
	
	/**
	 * Get settings collection. You are not getting settings from here.
	 * You need to do $this->getSettings($component)->getRecords();
	 *
	 * @param  String                      $component
	 * @return Object[Waveself_Settings]
	 * @throws Waveself_Exception          If component cannot be found inside of storage!
	 */
	public function getSettings($component)
	{
		if(! isset(self::$_settings[$component])) {
			throw new Waveself_Exception("Settings '{$component}' do not exist! Did you forget to load it?");
		}
		return self::$_settings[$component];
	}
	
	/**
	 * Get Waveself Engine Bootstrap Component
	 *
	 * @return  Waveself_Engine_Bootstrap
	 * @throws  Waveself_Exception          If engine is not bootstraped! Impossible but still :)
	 */
	public function getBootstrap()
	{
		if (!isset(self::$_engineComponents['bootstrap'])) {
			throw new Waveself_Exception("You need to bootstrap engine first! Read docs");
		}
		return self::$_engineComponents['bootstrap'];
	}
	
	/**
	 * Get Waveself Engine Router Component
	 *
	 * @return  Waveself_Engine_Router
	 * @throws  Waveself_Exception          If engine is not bootstraped! Impossible but still :)
	 */
	public function getRouter()
	{
		if (!isset(self::$_engineComponents['router'])) {
			throw new Waveself_Exception("You need to bootstrap engine first! Read docs");
		}
		return self::$_engineComponents['router'];
	}
	
	/**
	 * Get Waveself Engine Project Component
	 *
	 * @return  Waveself_Engine_Router
	 * @throws  Waveself_Exception          If engine is not bootstraped! Impossible but still :)
	 */
	public function getProject()
	{
		if (!isset(self::$_engineComponents['project'])) {
			throw new Waveself_Exception("You need to bootstrap engine first! Read docs");
		}
		return self::$_engineComponents['project'];
	}


}
